package com.sline.Reflect;

import java.io.BufferedReader;
import java.io.FileReader;

public class Demo2_Reflect {
    public static void main(String[] args) throws Exception {
        BufferedReader bf = new BufferedReader(new FileReader("config.properties"));
        String classStr = bf.readLine();
        Class clazz = Class.forName(classStr);
        Fruit f = (Fruit) clazz.newInstance();
        Juicer juicer = new Juicer();
        juicer.doJuice(f);
    }
}

class Juicer {
    public void doJuice(Fruit fruit) {
        fruit.squeeze();
    }
}

interface Fruit {
    public void squeeze();
}

class Apple implements Fruit {
    @Override
    public void squeeze() {
        System.out.println("榨苹果汁");
    }
}

class Orange implements Fruit {
    @Override
    public void squeeze() {
        System.out.println("榨橘子汁");
    }
}